package com.hjsmallfly.syllabus.other

import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.CircleCrop
import com.hjsmallfly.syllabus.R
import com.hjsmallfly.syllabus.base.BaseKtActivity
import com.hjsmallfly.syllabus.ext.compat
import com.hjsmallfly.syllabus.ext.setBackIcon
import com.hjsmallfly.syllabus.ext.titleText
import com.latsen.pawfit.common.util.glide.GlideImageLoader
import com.latsen.pawfit.common.util.glide.GlideImageOptions
import com.latsen.pawfit.common.util.glide.GlideResource
import com.latsen.pawfit.ext.dp2px
import jp.wasabeef.glide.transformations.RoundedCornersTransformation
import kotlinx.android.synthetic.main.activity_about_us.*
import kotlinx.android.synthetic.main.view_toolbar.*

class AboutUsKtActivity : BaseKtActivity() {

    override fun init(savedInstanceState: Bundle?) {
        initTitle()
        initProfile()
    }

    private fun initProfile() {
        GlideImageLoader.load(
            syllabusIconView,
            GlideResource(R.drawable.ic_syllabus_icon),
            GlideImageOptions(this).apply {
                transforms(RoundedCornersTransformation(dp2px(4f), 0), CenterCrop())
            })
        val map = mapOf(
            iOSDeveloperHeadImageView to "https://avatars3.githubusercontent.com/u/11157226?v=3&s=64",
            backendDeveloperHeadImageView to "https://avatars1.githubusercontent.com/u/12378280?v=3&s=64",
            androidDeveloperHeadImageView to "https://avatars3.githubusercontent.com/u/12541192?v=3&s=64"
        )
        for ((iv, url) in map) {
            GlideImageLoader.load(iv, GlideResource(url), GlideImageOptions(this).apply {
                transforms(RoundedCornersTransformation(dp2px(4f), 0), CenterCrop())
            })
        }
    }

    private fun initTitle() {
        tb_title.compat()
        tb_title.setBackIcon()
        tb_title.setNavigationOnClickListener {
            finish()
        }
        tb_title.titleText = "关于我们"
    }

    override fun getContentView() = R.layout.activity_about_us

    companion object {
        @JvmStatic
        fun newIntent(context: Context) = Intent(context, AboutUsKtActivity::class.java)
    }
}